package com.jidu.controller;

import java.util.List;

import com.jidu.domain.JpChangeClassRecord;
import com.jidu.service.IJpChangeClassRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.jidu.common.annotation.Log;
import com.jidu.common.core.controller.BaseController;
import com.jidu.common.core.domain.AjaxResult;
import com.jidu.common.enums.BusinessType;
import com.jidu.common.core.page.TableDataInfo;

/**
 * 转班记录Controller
 * 
 * @author ruoyi
 * @date 2024-07-24
 */
@Slf4j
@Api(tags = "转班记录 controller")
@RestController
@RequestMapping("/system/record")
public class JpChangeClassRecordController extends BaseController
{
    @Autowired
    private IJpChangeClassRecordService jpChangeClassRecordService;

    /**
     * 查询转班记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(JpChangeClassRecord jpChangeClassRecord)
    {
        startPage();
        List<JpChangeClassRecord> list = jpChangeClassRecordService.selectJpChangeClassRecordList(jpChangeClassRecord);
        return getDataTable(list);
    }

//    /**
//     * 导出转班记录列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:record:export')")
//    @Log(title = "转班记录", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, JpChangeClassRecord jpChangeClassRecord)
//    {
//        List<JpChangeClassRecord> list = jpChangeClassRecordService.selectJpChangeClassRecordList(jpChangeClassRecord);
//        ExcelUtil<JpChangeClassRecord> util = new ExcelUtil<JpChangeClassRecord>(JpChangeClassRecord.class);
//        util.exportExcel(response, list, "转班记录数据");
//    }

    /**
     * 获取转班记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jpChangeClassRecordService.selectJpChangeClassRecordById(id));
    }

    /**
     * 新增转班记录
     * 会在课程关系表新加一条记录。is_change_class = 2 原数据为 1（原纪录不会显示出来），并且会在jp_change_class_record 加一条记录
     */
    @ApiOperation(value = "转班")
    @PreAuthorize("@ss.hasPermi('system:record:add')")
    @Log(title = "转班", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JpChangeClassRecord jpChangeClassRecord)
    {
        return toAjax(jpChangeClassRecordService.insertJpChangeClassRecord(jpChangeClassRecord));
    }

    /**
     * 转班记录列表
     */
    @ApiOperation(value = "转班记录列表")
//    @PreAuthorize("@ss.hasPermi('system:record:')")
    @GetMapping("/change/list")
    public AjaxResult changeList(@RequestParam(value = "studentId")Long studentId,
                                 @RequestParam(value = "courseStudentId")Long courseStudentId){
        return AjaxResult.success(jpChangeClassRecordService.changeList(studentId,courseStudentId));
    }
//    /**
//     * 修改转班记录
//     */
//    @PreAuthorize("@ss.hasPermi('system:record:edit')")
//    @Log(title = "转班记录", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody JpChangeClassRecord jpChangeClassRecord)
//    {
//        return toAjax(jpChangeClassRecordService.updateJpChangeClassRecord(jpChangeClassRecord));
//    }

//    /**
//     * 删除转班记录
//     */
//    @PreAuthorize("@ss.hasPermi('system:record:remove')")
//    @Log(title = "转班记录", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(jpChangeClassRecordService.deleteJpChangeClassRecordByIds(ids));
//    }
}
